package com.example.module.spinner;

import android.app.Activity;
import android.content.Context;
import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;

public class HelloAndroidAgain extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new MyTestView(this));
	}

	private static class MyTestView extends View {
		public MyTestView(Context context) {
			super(context);
			setMinimumWidth(200);
			setMinimumHeight(200);
			// camera = new Camera();
		}

		private Camera camera = new Camera();

		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);
			camera.save();
			camera.rotateY(60f);
			camera.applyToCanvas(canvas);
			canvas.drawColor(Color.DKGRAY);
			Paint paint = new Paint();
			paint.setTextSize(24);
			// front left wheel
			canvas.save();
			canvas.translate(50f, 50f);// xCtr, yCtr
			paint.setColor(Color.GREEN);
			canvas.drawCircle(0, 0, 30, paint);
			paint.setColor(Color.WHITE);
			canvas.drawText("FL", -10, 10, paint);// string
			canvas.restore();
			// front right wheel
			canvas.save();
			canvas.translate(150f, 50f);
			paint.setColor(Color.GREEN);
			canvas.drawCircle(0, 0, 30, paint);
			paint.setColor(Color.WHITE);
			canvas.drawText("FR", -10, 10, paint);
			canvas.restore();
			// rear left wheel
			canvas.save();
			canvas.translate(50f, 150f);
			paint.setColor(Color.GREEN);
			canvas.drawCircle(0, 0, 30, paint);
			paint.setColor(Color.WHITE);
			canvas.drawText("BL", -10, 10, paint);
			canvas.restore();
			// rear right wheel
			canvas.save();
			canvas.translate(150f, 150f);
			paint.setColor(Color.GREEN);
			canvas.drawCircle(0, 0, 30, paint);
			paint.setColor(Color.WHITE);
			canvas.drawText("BR", -10, 10, paint);
			canvas.restore();
			// body
			canvas.save();
			canvas.translate(100f, 100f);
			paint.setColor(Color.RED);
			canvas.drawRect(-50, -50, 50, 50, paint);
			canvas.restore();
			camera.restore();
		}

		@Override
		protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
			super.onMeasure(widthMeasureSpec, heightMeasureSpec);
			setMeasuredDimension(getSuggestedMinimumWidth(),
					getSuggestedMinimumHeight());
		}
	}
}
